<?php
namespace app\admin\logic;
use app\admin\BaseController;
use app\admin\model\Goods;
use think\facade\Request;
use think\facade\View;

class GoodsLogic extends BaseController
{
    public static function getWhere()
    {
        $param=Request::param();
        $where=[];
        if (isset($param['keywords']) &&!empty($param['keywords']))    $where['keywords']=$param['keywords'];
        if (isset($param['is_show'])  && $param['is_show'] !='')       $where['is_show']=$param['is_show'];
        if (isset($param['is_hot'])   && $param['is_hot'] !='')        $where['is_hot']=$param['is_hot'];
        if (isset($param['is_down'])  && $param['is_down'] !='')       $where['is_down']=$param['is_down'];
        if (isset($param['cid'])      && $param['cid'] !='')           $where['cid']=$param['cid'];
        $cid=Request::get('cid','');
        View::assign('cid',$cid);
        $where['delete_time']=null;
        View::assign($where);
        return $where;
    }

    public static function setAddData()
    {
        $data=Request::post();
        $data['addtime']=time();
        return $data;
    }

    public static function getNextCate($cate_list,$parentid)
    {
        $cate = [];
        foreach ($cate_list as $v){
            if ($v['parentid'] == $parentid){
                $cate[$v['id']] = $v;
                $cate[$v['id']]['next'] = self::getNextCate($cate_list,$v['id']);
            }
        }
        return $cate;
    }
}